﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace CPPEI.Coolzon.Designer.Views
{
    public static class RenameCommand
    {
        public static void Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if(UIContext.Current.CurrentSelectedNode != null)
            {
                if (Designtime.Metadata.VSFileMgr.GoToCheckOut(UIContext.Current.LocalWorkSpace.LocalPath, UIContext.Current.CurrentSolution.ID, UIContext.Current.CurrentSelectedNode.ID))
                {
                    UIContext.Current.CurrentSelectedNode.NodeStatus = NodeStatus.CheckOut;
                    UIContext.Current.CurrentSelectedNode.IsInEditMode = true;
                }
            }
        }
        public static void CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (UIContext.Current.CurrentSelectedNode != null && UIContext.Current.CurrentSelectedNode.NodeType == NodeType.Folder && !UIContext.Current.CurrentSelectedNode.Caption.StartsWith("$"))
            {
                e.CanExecute = true;
            }
            else
            {
                e.CanExecute = false;
            }
        }
    }
}
